﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using BLL;

namespace CorporateGymManagementSystem
{
    /// <summary>
    /// Interaction logic for PasswordChangeScreen.xaml
    /// </summary>
    public partial class PasswordChangeWindow : Window
    {
        public PasswordChangeWindow()
        {
            InitializeComponent();
        }

        public PasswordChangeWindow(string i_UserName)
        {
            InitializeComponent();
            userNameBox.Text = i_UserName;
        }

        private void submitButton_Click(object sender, RoutedEventArgs e)
        {
            string oldpassword = oldPasswordBox.Password;
            string newpassword = newPasswordBox.Password;
            string newpasswordretype = retypeNewPasswordBox.Password;
            string userName = userNameBox.Text;
            bool succeeded = GymWorkerManager.Instance.ChangePassword(userName, oldpassword, newpassword, newpasswordretype);
            if (succeeded)
            {
                this.Close();
            }
            else
            {
                status.Content = "Some of the fields were incorrect";
            }
        }
    }
}
